//
//  DataManager.m
//  Recipe
//
//  Created by YaSha_Tom on 2018/12/17.
//  Copyright © 2018年 YaSha-Tom. All rights reserved.
//

#import "DataManager.h"
#import <MJExtension.h>
#import "CategoryModel.h"
#import "FoodListModel.h"

@implementation DataManager

static DataManager *_datamanager = nil;
+ (DataManager *)sharedDataManager {
    
    if (!_datamanager) {
        
        _datamanager = [[DataManager alloc] init];
    }
    
    return _datamanager;
}
+ (NSArray *)getCategoryListData:(id)responseObject {
    NSArray *orderArray = responseObject[@"result"];
    NSMutableArray *mutableArray = [NSMutableArray array];
    for (NSDictionary *dic in orderArray) {
        //字典转model的第三方MJExtension
        CategoryModel *model = [CategoryModel mj_objectWithKeyValues:dic];
        [mutableArray addObject:model];
    }
    return [mutableArray copy];
}

+ (NSArray *)getFoodListData:(id)responseObject {
    NSArray *orderArray = responseObject[@"result"];
    NSMutableArray *mutableArray = [NSMutableArray array];
    for (NSDictionary *dic in orderArray) {
        //字典转model的第三方MJExtension
        NSMutableArray *array = [NSMutableArray array];
        for (NSDictionary *dic1 in dic[@"list"]) {
            CategoryModel *model = [CategoryModel mj_objectWithKeyValues:dic1];
            [array addObject:model];
        }
        [mutableArray addObject:array];
    }
    return [mutableArray copy];
}
+ (NSArray *)getFoodData:(id)responseObject {
    NSArray *orderArray = responseObject[@"result"][@"data"];
    NSMutableArray *mutableArray = [NSMutableArray array];
    for (NSDictionary *dic in orderArray) {
        //字典转model的第三方MJExtension
        FoodListModel *model = [FoodListModel mj_objectWithKeyValues:dic];
        [mutableArray addObject:model];
    }
    return [mutableArray copy];
}

@end
